package cn.lan.scau_hotel_service.controller;

import cn.lan.scau_hotel_service.entity.Hotel;
import cn.lan.scau_hotel_service.entity.User;
import cn.lan.scau_hotel_service.service.HotelService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/hotel")
public class HotelController {

    @Autowired
    private HotelService hotelService;

    @RequestMapping(value="", method= RequestMethod.POST)
    public String addAndUpdateHotel(@RequestBody Hotel hotel) {
        return "保存更新结果："+ hotelService.saveHotel(hotel);
    }

    @RequestMapping(value="", method= RequestMethod.DELETE)
    public String deleteHotel(@RequestParam("openid")int id) {
        return "删除结果："+ hotelService.deleteHotelById(id);
    }

    @ApiOperation(value="获取酒店列表", notes="post请求，返回酒店列表")
    @RequestMapping(value="/list", method= RequestMethod.POST)
    public List<Hotel> getHotelList(){
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"   +hotelService);
        return hotelService.findAll();
    }

}
